﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;

namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class CTKHDatHangBlo
    {
        #region "Khai báo các biến"
        private CTKHDatHangDAO da;
        private CTKHDatHangDTO _CTKHDH;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public CTKHDatHangDTO CTKHDH
        {
            get { return _CTKHDH; }
            set { _CTKHDH = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public CTKHDatHangBlo()
        {            
            da = new CTKHDatHangDAO();
        }
        public bool InsertCTKHDatHang(string mamh, string makhdh, int soluong, string dvt, double dongia, float chietkhau, double thanhtien, bool dagiao)
        {
            _CTKHDH = new CTKHDatHangDTO(mamh, makhdh, soluong, dvt, dongia,chietkhau,thanhtien,dagiao);
            if (!da.InsertCTKHDatHang(CTKHDH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateCTKHDatHang(string mamh, string makhdh, int soluong, string dvt, double dongia, float chietkhau, double thanhtien, bool dagiao)
        {
            _CTKHDH = new CTKHDatHangDTO(mamh, makhdh, soluong, dvt, dongia, chietkhau, thanhtien, dagiao);
            if (!da.UpdateCTKHDatHang(CTKHDH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteCTKHDatHang(string maMH,string maKHDH)
        {
            if (!da.DeleteCTKHDatHang(maMH,maKHDH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_CTKHDatHang()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_CTKHDatHang();
            return ds;
        }
        #endregion 
    }
}